# _*_ coding: utf-8 _*_
import pandas as pd
import numpy as np

s = pd.Series([1, 3, 5, np.nan, 6, 8])
print(s)

dates = pd.date_range('20170101', periods=7)

print(dates)

print('-' * 32)

df = pd.DataFrame(np.random.randn(7, 5), index=dates, columns=list('abcdE'))
print(df)
'''df:
                   a         b         c         d         E
2017-01-01  0.750101  0.677516  0.383146 -0.499854  0.978401
2017-01-02  0.822642  2.368117  0.025207  2.535850 -0.454222
2017-01-03 -1.549397  0.053803  0.392331 -0.466844 -0.380658
2017-01-04  1.319631  0.704077  1.000361 -0.784026 -2.337837
2017-01-05 -0.743598  0.835579 -0.769887 -0.288903 -0.624269
2017-01-06  0.543858  1.112082  0.363815 -0.044682  1.287864
2017-01-07  0.465140 -0.959645  1.479446  0.026763  0.634880
'''

print(np.random.randn(2, 2))
'''np.random.randn(2, 2)

[[ 0.40191206 -0.30932264]
 [ 0.06434884 -0.63717624]]
'''

'''
numpy.dtype
'''
print(np.dtype('i4'))  # int32

print(np.dtype(np.int32))  # int32
'''
多维数组的切片&索引
'''
s1 = slice(2, 7, 2)  # (start=2,stop=7,step=2)
print((np.arange(10)[s1]))  # [2, 4, 6]

print(np.arange(10)[2:7:2])  # 同样效果，[2, 4, 6]

a = np.array([[1, 2, 3], [3, 4, 5], [4, 5, 6]])
'''
[[1 2 3]
 [3 4 5]
 [4 5 6]]
'''
print(a)
print('第二列的元素是：')  # [2 4 5]
print(a[..., 1])  # 每一行的第1个（从0开始）

print('第二行的元素是：')  # [3 4 5]
print(a[1, ...])  # 第1行的每一列（从0开始）

print('第二列及其剩余元素是：')
'''
[[2 3]
 [4 5]
 [5 6]]
'''
print(a[..., 1:])

print('第二行及其剩余元素是：')
'''
[[3 4 5]
 [4 5 6]]
'''
print(a[1:, ...])
